package service;

import com.javaweb.config.SpringConfig;
import com.javaweb.dao.ArticleDao;
import com.javaweb.dao.UserDao;
import com.javaweb.model.User;
import com.javaweb.service.UserService;
import com.javaweb.service.dto.PageResult;
import lombok.extern.slf4j.Slf4j;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.transaction.PlatformTransactionManager;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = SpringConfig.class)
@Slf4j
public class usertest {
    @Autowired
    UserService userService;


@Test
    public void testuser(){
    System.out.println(userService.queryByName("lisi"));
}
@Test
    public void testuser1(){
    User user = new User()
            .setName("newUser1")
            .setPassword("password123")
            .setSalt("salt")
            .setCreateTime(new java.util.Date())
            .setGender(1);
    int result = userService.register(user);
    Assert.assertEquals(1, result); // 期望注册成功
    System.out.println("测试register方法，注册结果: " + result);
}
@Test
    public void testuser2(){
    PageResult pageResult = userService.queryUsers(null, 1, 11); // 查询第一页，页面大小为10

System.out.println(pageResult);

}

}
